
package com.dps.omc.service.impl;
import com.dps.omc.enumer.EnumJobState;
import com.dps.omc.model.User;
import com.dps.omc.service.IJobLogService;
import com.dps.common.utils.IdGenerator;
import com.dps.omc.service.IJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dps.common.service.impl.AbstractPageService;
import com.dps.omc.dao.IJobDAO;
import com.dps.omc.model.Job;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;

@SuppressWarnings("unchecked")
@Service("JobServiceImpl")

public class JobServiceImpl extends AbstractPageService<IJobDAO,Job> implements IJobService {

	@Autowired
	private IJobDAO jobDAO;
	@Autowired
	private IJobLogService jobLogService;
	@Override
	public boolean getEnableDataPerm() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public IJobDAO getDao() {
		return jobDAO;
	}

	@Override
	public Job add(Job job,User lastModified) {
		if((StringUtils.isEmpty(job.getId())))
		{
			job.setId(IdGenerator.createNewId());
		}
		getDao().insert(job);
//		User lastModified = new User();
		jobLogService.createLog(job,lastModified);
		return job;
	}

	@Override
	public void update(Job job,User lastModified) {
		getDao().update(job);
//		User lastModified = new User();
		jobLogService.createLog(job,lastModified);
	}

	@Override
	public List<Job> queryByCreateDateAndStatus(Date queryStart, Date queryEnd, EnumJobState status) {
		return getDao().queryByCreateDateAndStatus(queryStart,queryEnd,status);
	}
}
